Introduction
CBWIRE is a ColdBox module that uses Livewire and Alpine.js to help you build modern, reactive CFML applications in record time without building backend APIs.
Last updated
Was this helpful?
CBWIRE is a ColdBox module that uses Livewire and Alpine.js to help you build modern, reactive CFML applications in record time without building backend APIs.
Last updated
Was this helpful?
Download and install . From your CLI, start CommandBox by typing 'box'. Then run the following:
Let's insert a counter element into our Main layout using wire( "Counter" ).
You now have a reactive counter that increments when you click the plus button without any page refreshing or writing JavaScript! 🤯
CBWIRE renders the component with default values (starting at 0).
A button click triggers Livewire.js to send a request to the server.
CBWIRE processes the request, runs increment()
, and updates the data.
The updated HTML is sent back in the response.
Livewire.js refreshes the display using DOM comparison.
We developed a responsive counter.
We avoided writing any JavaScript code.
We didn't need to create an API.
There was no need for page refreshes.
We skipped using webpack or dealing with JavaScript compilation.
The example shows how easily components interact with your CFML back-end. But for quick UI updates, JavaScript can handle changes without unnecessary server requests. While we don’t need a request to increment the counter, we might if we want to save it. This is where CBWIRE and Alpine work perfectly together.
Below, let's change our component to use Alpine.js and add a method to save the counter.
The counter updates instantly on the client side, sending a server request only when clicking "Save" to store the value in the session. On page load, onMount()
sets the counter from the session. Using $wire
, Alpine communicates with the component, giving full control over server requests. CBWIRE is redefining CFML development—we think you'll love it!
Let's define our Counter .
Finally, define our counter .
We stayed entirely within the CFML environment.
is a lightweight JavaScript framework that was built for simplicity and designed to work alongside Livewire ( and therefore CBWIRE ).
CBWIRE uses the JavaScript bits from and for its DOM diffing and client-side functionality. CBWIRE wouldn't exist without the incredible work of , the creator of both Livewire and Alpine. CBWIRE was created to bring these excellent tools into the ColdBox and CFML ecosystem.
The CBWIRE module for ColdBox is written and maintained by , , and .
Please consider becoming one of our lovingly esteemed .